#include <gtest/gtest.h>

#include "ConnectionPool.h"
#include "configuration.h"

TEST(simple_test, acquire_pool) {
  //测试单例
  auto& instance_1 =
      ConnectionPool::getConnectionPool(dbname, user, password, host, port);
  auto& instance_2 =
      ConnectionPool::getConnectionPool("xxx", "xxx", "xxx", "xxx", "xxx");
  ASSERT_EQ(&instance_1, &instance_2) << "not single instance";
}

TEST(simple_test, get_connection) {
  auto p = ConnectionPool::getConnectionPool(dbname, user, password, host, port)
               .getConnection();
  auto& conn = p->getConn();
  ASSERT_TRUE(p != nullptr) << "can't get connection";
}